package com.game;

import android.content.Context;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class GameView extends SurfaceView implements SurfaceHolder.Callback{
	private GameThread gameThread;
	private Context context;
	public GameView(Context context) {
		super(context);
		this.context = context;
		//this.requestFocus();
		//this.setFocusableInTouchMode(true);
		getHolder().addCallback(this);
		getHolder().setType(SurfaceHolder.SURFACE_TYPE_HARDWARE);	
	}
	
	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		gameThread = new GameThread(context, this);
		gameThread.start();
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		gameThread.requestExitAndWait();
		gameThread = null;
	}
}
